<?php

require_once 'jsonToArrayParser.php';

$return = array();
if (empty($_GET['email'])) {
    $return['error'] = true;
    $return['msg'] = 'You did not enter you email.';
}
else {
    $return['error'] = false;
    $return['msg'] = 'You\'ve entered: ' . $_GET['email'] . '.';
}



		$ch = curl_init();

        // set URL and other appropriate options
        curl_setopt($ch, CURLOPT_URL, $_GET['email']);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

        // grab URL and pass it to the browser
        $data = curl_exec($ch);

        // close cURL resource, and free up system resources
        curl_close($ch);

        $jsonarray = json_decode($data, false);
?>

<div>
	<h2>You were looking for: <?php echo $jsonarray->phrase; ?></h2>
	<?php
	foreach ( $jsonarray->tuc as $tuc )
	{
	    echo "<h3>{$tuc->phrase->text}</h3>\n";
	}
	?>
</div>